<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/common.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<meta charset="utf-8">
<head></head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-ledger-add" enctype="multipart/form-data">
			<input type="hidden" name="userId" class="form-control" value="${user.userId }">
			<div class="form-group">
				<label class="col-sm-3 control-label">原始密码：</label>
				<div class="col-sm-8">
					<input id="oldpwd" name="oldpwd" class="form-control" type="password">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">新密码：</label>
				<div class="col-sm-8">
					<input name="pwd" id="newpwd" class="form-control" type="password">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">确定密码：</label>
				<div class="col-sm-8">
					<input id="checkpwd" class="form-control" type="password">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">&nbsp;</label>
				<div class="col-sm-8">
					<a class="btn btn-primary btn-del" onclick="submitHandler()">
						<i class="fa fa-play"></i>
						修改
					</a>
				</div>
			</div>
		</form>
	</div>
	<script type="text/javascript">
		var prefix = "${ctx}/sys/index"
		$("#form-ledger-add").validate({
			rules : {
				newpwd : {
					required : true,
				},
				checkpwd : {
					required : true,
				},
				oldpwd : {
					required : true,
				},
			}
		});
	
		function submitHandler() {
			if ($.validate.form()) {
				var newpwd = $("#newpwd").val();
				var checkpwd = $("#checkpwd").val();
				if (newpwd != checkpwd) {
					alert("2次密码不一致");
					return;
				}
	
				if (!confirm("你确定该操作？")) {
					return;
				}
				$.operate.save(prefix + "/changePwd", $('#form-ledger-add').serialize());
			}
		}
	</script>
</body>
</html>
